package example.mydemo.service;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.widget.Toast;

public class MyService extends Service{
	
	public static MediaPlayer music;
	
	@Override
	public void onCreate(){
		Toast.makeText(getApplicationContext(), "Service has created!", Toast.LENGTH_SHORT).show();
		music = MediaPlayer.create(this, R.raw.anniversary);
		music.setLooping(true);
	}
	
	@Override
	public void onStart(Intent intent, int startid){
		Toast.makeText(getApplicationContext(), "My Service is started!", Toast.LENGTH_SHORT).show();
		music.start();
	}
	
	@Override
	public void onDestroy(){
		music.stop();
		Toast.makeText(getApplicationContext(), R.string.destroy_service, Toast.LENGTH_SHORT).show();
		super.onDestroy();
	}
	

	@Override
	public IBinder onBind(Intent intent) {
		// TODO Auto-generated method stub
		return null;
	}
	
}
